var crypto = require('crypto');
var secp256k1 = require('secp256k1');
var keccak = require('keccak');

//获得随机的32个字节作为私钥，在使用中，请注意随机数来源的安全
var privateKey = crypto.randomBytes(32);
//获得公钥
var publicKey = secp256k1.publicKeyCreate(privateKey, false).slice(1);
//获得地址
var address = keccak('keccak256').update(publicKey).digest().slice(-20);

console.log('public key', publicKey.toString('hex'));
console.log('private key', privateKey.toString('hex'));
console.log('address', '0x' + address.toString('hex'));